package com.microservice.api.system;

import com.microservice.api.system.fallbackFactory.RemoteSystemFallbackFactory;
import com.microservice.core.constant.FeignConstants;
import com.microservice.core.domain.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 下面的方式二选一,第一种请求从网关走(url配置在nacos上)，第二种请求直接请求服务提供方
 * 不过一般情况下 不需要从网关gateway走，登录认证后直接请求服务提供方即可,这里只是为了测试
 */


//@FeignClient(contextId = "remoteSystemService",
//        value = FeignConstants.SYSTEM_SERVICE_NAME,
//        url = "${service.gateway-base-url}",
//        path = FeignConstants.PREFIX_SYSTEM_PATH,
//        fallbackFactory = RemoteSystemFallbackFactory.class)

@FeignClient(contextId = "remoteSystemService",
        value = FeignConstants.SYSTEM_SERVICE_NAME,
        fallbackFactory = RemoteSystemFallbackFactory.class)
public interface RemoteSystemService {
    //下面两个方法属于登录时查询用户信息的，不应该从网关gateway走
    @GetMapping("/user/getUserByUsername")
    AjaxResult getUserByUsername(@RequestParam("username") String username);

    @GetMapping("/user/getPermissionByUsername")
    AjaxResult getPermissionByUsername(@RequestParam("username")String username);

    @GetMapping("/user/getRoleByUsername")
    AjaxResult getRoleByUsername(@RequestParam("username") String username);

    @GetMapping("/user/userList")
    AjaxResult getUserList();
}
